package com.hn658.user.common.enums;

import com.hn658.user.common.expection.FilterException;

/**
 * 设备类型
 * @ClassName: DeviceType 
 * @Description: TODO
 * @author davidcun 
 * @date 2015年1月29日 下午3:28:25
 */
public enum DeviceType {
    Android(1, "安卓"),
    IOS(2, "苹果");

    private int code;

    private String name;

    DeviceType(int code, String name){
        this.code = code;
        this.name = name;
    }

    /**
     * @return the code
     */
    public int getCode() {
        return code;
    }

    public String getName(){
        return name;
    }

    /**
     * 根据code值获取对应的枚举
     * @param code
     * @return
     */
    public static DeviceType getTypeByCode(int code){
        for(DeviceType type : DeviceType.values()){
            if(type.getCode() == code){
                return type;
            }
        }

        throw new FilterException(FilterException.WrongDeviceType);
    }
}
